Fix unused stream in DefaultPluginXmlFactory#write#2303
Fix unused stream in DefaultPluginXmlFactory#write#2303Pankraz76 wants to merge 1 commit intoapache:masterfrom
stream in DefaultPluginXmlFactory#write#2303Conversation
| @@ -93,7 +93,7 @@ public void write(XmlWriterRequest<PluginDescriptor> request) throws XmlWriterEx | |||
| new PluginDescriptorStaxWriter().write(outputStream, content); | |||
| } else { | |||
| try (OutputStream os = Files.newOutputStream(path)) { | |||
There was a problem hiding this comment.
this looks like a critical bug and easy to prevent: https://checkstyle.sourceforge.io/checks/coding/unusedlocalvariable.html
There was a problem hiding this comment.
You wanna try adding the rule check to the PR ?
There was a problem hiding this comment.
its a bug in checkstyle we already have this checker in place:
There was a problem hiding this comment.
What version of checkstyle is in use?
Please share link to config also
There was a problem hiding this comment.
Please share link to config also
config is mystery ATM as it comes from cloud.
Will update, thanks.
There was a problem hiding this comment.
Congo is inherited from parent, but there is a way to override it and complement with the rules needed. You need to analyze how check style is configured in the parent.
There was a problem hiding this comment.
We have this bug reproducible and tested already in
So its nice to have this info, but not mandatory anymore.
|
[INFO] BUILD SUCCESS |
impl/maven-impl/src/main/java/org/apache/maven/impl/DefaultPluginXmlFactory.java
Outdated
Show resolved
Hide resolved
fix DefaultPluginXmlFactory#writefix unused stream in DefaultPluginXmlFactory#write
fix unused stream in DefaultPluginXmlFactory#write|
ty, will add tc as well. |
impl/maven-impl/src/main/java/org/apache/maven/impl/DefaultPluginXmlFactory.java
Show resolved
Hide resolved
| } | ||
|
|
||
| /** | ||
| * Simply converts the given content to an XML string. |
| } | ||
|
|
||
| /** | ||
| * Simply parse the given xml string. |
There was a problem hiding this comment.
less is more - kiss.
impl/maven-impl/src/main/java/org/apache/maven/impl/DefaultPluginXmlFactory.java
Show resolved
Hide resolved
| nonNull(request, "request"); | ||
| Path path = request.getPath(); | ||
| URL url = request.getURL(); | ||
| Reader reader = request.getReader(); |
There was a problem hiding this comment.
With this SOC, we get better visibility into the system and can avoid unnecessary complexity in the code. The current implementation is already clean and follows a functional OOP style, but it's not the final version. There's still room to extract dedicated abstraction layers to support more specialized responsibilities.
However, this approach currently mimics fields of a class, which introduces coupling and reduces cohesion. It leans into feature envy and bypasses SOLID design principles and established architectural patterns. We should aim to refactor accordingly.
stream in DefaultPluginXmlFactory#write
gnodet
left a comment
There was a problem hiding this comment.
Removed too much.
Please don't refactor too much without care.
yes
test first this changes already and things get simpler |
Not sure what you mean, but you removed support for URLs for no good reason. Your first commit what correct, now the PRs is not acceptable. |
stream in DefaultPluginXmlFactory#writeDefaultPluginXmlFactory#write
DefaultPluginXmlFactory#writeDefaultPluginXmlFactory#write
DefaultPluginXmlFactory#writeDefaultPluginXmlFactory#write
DefaultPluginXmlFactory#writeDefaultPluginXmlFactory#write
DefaultPluginXmlFactory#writestream in DefaultPluginXmlFactory#write
stream in DefaultPluginXmlFactory#writestream os in DefaultPluginXmlFactory#write
yes im sorry. lets SOC this merge and check on follow up to ship this fix and then improve test and everything else dedicated. Thanks for cooperation. Im learn a lot here. |
86735dd to
83cfb4b
Compare
stream os in DefaultPluginXmlFactory#writestream in DefaultPluginXmlFactory#write
sorry for high pace. Now bug and test with minimal fix ready to merge and follow up to dig deeper. |
|
You should not raise multiple PRs for the same thing, it becomes a mess and we have no idea what to review. Keep a single PR for one fix and update it. |
|
Yes, wanted to provide quick fix upfront. When merging this the other PR testing everything, therefore having bigger scope could be supplemented. |










Pull #2303: Fix unused
streaminDefaultPluginXmlFactory#writeredundantcode inDefaultPluginXmlFactory:write#2306DefaultModelProcessor#read#2304DefaultModelProcessor#read#2292Blindspot in checkstyle:
osis never used checkstyle/checkstyle#17036tc:
